package com.atguigu.day10;

import java.util.Objects;

public class Test12 {
    public static void main(String[] args) {
        Triangle t1 = new Triangle(3,4,5);
        Triangle t2 = new Triangle(4,5,6);
        System.out.println(t1);
        System.out.println(t2);

        System.out.println("t1的面积：" + t1.getArea());
        System.out.println("t1的周长：" + t1.getPiremeter());
        System.out.println("t2的面积：" + t2.getArea());
        System.out.println("t2的面积：" + t2.getPiremeter());

        System.out.println("t1和t2是否相同：" + t1.equals(t2));
    }
}
class Triangle{
    private double a,b,c;

    public Triangle() {
    }

    public Triangle(double a, double b, double c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    public double getA() {
        return a;
    }

    public void setA(double a) {
        this.a = a;
    }

    public double getB() {
        return b;
    }

    public void setB(double b) {
        this.b = b;
    }

    public double getC() {
        return c;
    }

    public void setC(double c) {
        this.c = c;
    }

    @Override
    public String toString() {
        return "Triangle{" +
                "a=" + a +
                ", b=" + b +
                ", c=" + c +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Triangle triangle = (Triangle) o;
        return Double.compare(triangle.a, a) == 0 &&
                Double.compare(triangle.b, b) == 0 &&
                Double.compare(triangle.c, c) == 0;
    }
    public double getArea(){
        double d = (a + b + c) / 2;
        return Math.sqrt(d * (d - a) * (d - b) * (d - c));
    }
    public double getPiremeter(){
        return a+b+c;
    }
}
